package com.baimawangzi.recovery.servlet.goods;

import com.baimawangzi.recovery.service.impl.GoodsServiveImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/goodsdelete.do")
public class GoodsDeleteServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        GoodsServiveImpl goodsServive = new GoodsServiveImpl();
        //解析url参数
        int id = Integer.parseInt(req.getParameter("id"));
        int a = goodsServive.delete(id);
        if(a>0){//返回的信息
            req.setAttribute("msg","删除回收物成功");
        }
        else {
            req.setAttribute("msg","删除回收物失败");
        }
        try {
            req.getRequestDispatcher("goodslist.do").forward(req,resp);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
